﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace PedesTrainProject.Traffic
{
    [Serializable()]
    public class Jam : ISerializable
    {
        private DateTime start_time;
        private DateTime end_time;
        private int max_cars;
        private double lenght;
        private Grid.Lane lane;

        public Jam()
        {
        }

        // Calculates period of jam upon start_time and end_time
        public double calculateLength()
        {
            double calculatedLenght = 0.0;

            return calculatedLenght;
        }

        public double checkJam()
        {
            double jams = 0.0;

            return jams;
        }

        #region Serialize
        public Jam(SerializationInfo info, StreamingContext ctxt)
        {
            this.start_time = (DateTime)info.GetValue("Start_Time", typeof(DateTime));
            this.end_time = (DateTime)info.GetValue("End_Time", typeof(DateTime));
            this.max_cars = (int)info.GetValue("Max_Cars", typeof(int));
            this.lenght = (double)info.GetValue("Lenght", typeof(double));
            this.lane = (Grid.Lane)info.GetValue("Lane", typeof(Grid.Lane));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("Start_Time", this.start_time);
            info.AddValue("End_Time", this.end_time);
            info.AddValue("Max_Cars", this.max_cars);
            info.AddValue("Lenght", this.lenght);
            info.AddValue("Lane", this.lane);
        }
        #endregion
    }
}
